package me.gm.stcont.validator;

import me.gm.stcont.model.Store;

import org.apache.log4j.Logger;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

public class StoreValidator implements Validator {

	private Logger logger;

	public StoreValidator() {
		this.logger = Logger.getLogger(this.getClass());
	}

	public boolean supports(Class<?> clazz) {
		return Store.class.equals(clazz);
	}

	public void validate(Object target, Errors errors) {
		logger.debug("started validate");

		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "fancyName",
				"store.fancyName.empty");

		logger.debug("finished validate");
	}

}
